﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using PccCommonForC;
using System.Security.Cryptography;

public partial class Manager_PrivateInfo_ChangePassword : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["AdminUserID"] == null)
        {
            Response.Write("<script language=javascript>alert('Time is out.');window.open('../Default.aspx','_top');</script>");
            return;
        }
    }
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        PccMsg msg = new PccMsg();
        clsCommon clsCom = new clsCommon();
        RijndaelManaged mobjCryptoService = new RijndaelManaged();
        EncrypKey clsEncryp = new EncrypKey(mobjCryptoService);
        string UserID = Session["AdminUserID"].ToString();
        if (Request.QueryString["UserID"] != "" && Request.QueryString["UserID"] != null)
        {
            if (Session["IsAdmin"] != "S")
            {
                Response.Redirect("../User/Customer.aspx");
            }
            UserID = Request.QueryString["UserID"];
        }

        msg.CreateFirstNode("UserID", UserID);
        msg.CreateFirstNode("Password", clsEncryp.Encrypting((txtPassword.Text), System.Configuration.ConfigurationManager.AppSettings["EncrypKey"]));
        msg.CreateFirstNode("Status", "");
        msg.CreateFirstNode("UpdID", "0");

        clsWebShop cls = new clsWebShop();
        cls.Upd_shr_User_Password(msg.GetXmlStr.ToString());
        if (Request.QueryString["UserID"] != "" && Request.QueryString["UserID"] != null)
            Response.Redirect("../User/Customer.aspx");
        else
             ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script> alert('Dữ liệu đã cập nhật thành công');</script>");

    }
}
